﻿using System.Linq;
using System.Windows;
using System.Windows.Controls;

namespace WP7.Extensions.Extensions
{
    public static class ListBoxExtensions
    {
        public static void HideUIElement(this ListBox self, object obj)
        {
            var item = self.ItemContainerGenerator.ContainerFromItem(obj) as UIElement;
            item.Opacity = 0;
        }

        public static UIElement GetUIElement(this ListBox self, object obj)
        {
            return self.ItemContainerGenerator.ContainerFromItem(obj) as UIElement;
        }

        public static void ShowAllUIElement(this ListBox self)
        {
            foreach (var ui in self.Items.Select(i => self.ItemContainerGenerator.ContainerFromItem(i) as UIElement))
            {
                ui.Opacity = 1;
            }
        }
    }
}
